<!--
 * @Descripttion: 
 * @Author: liuYaoYu
 * @Date: 2021-12-16 16:13:32
 * @LastEditors: liuYaoYu
 * @LastEditTime: 2021-12-16 16:16:43
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 边界符 ^ $
        var rg = /abc/; // 这要包含 有abc 返回都是true
        console.log(rg.test("abc"));
        console.log(rg.test("abcd"));
        console.log(rg.test("aabcd"));
        console.log('---------------');
        var reg=/^abc/;
        console.log(reg.test("abc"));//true
        console.log(reg.test("abcd"));//true
        console.log(reg.test("aabcd"));//false
        console.log('---------------');
        var regrex=/^abc$/;// 已abc开头已abc结尾
        console.log(regrex.test("abc"))//true
        console.log(regrex.test("abcd"))//false
        console.log(regrex.test("aabcd"))//false
        
    </script>
</body>
</html>